//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#ifndef __FILEDISK_H__
#define __FILEDISK_H__

#include <driver.h>
#include <filedisk_data.h>

class CFileDisk : public CDeviceDriver
{
public:

    CFileDisk();

    ~CFileDisk();

    CARAPI Read(
        /* [in] */ Int64 u64Offset,
        /* [in] */ Int32 bytesToRead,
        /* [out] */ MemoryBuf * pBuffer,
        /* [out] */ IEvent * * ppCompletionEvent);

    CARAPI Write(
        /* [in] */ Int64 u64Offset,
        /* [in] */ const MemoryBuf & buffer,
        /* [out] */ Int32 * pBytesWritten,
        /* [out] */ IEvent * * ppCompletionEvent);

    CARAPI Control(
        /* [in] */ Handle32 nControlCode,
        /* [in] */ const MemoryBuf & inBuffer,
        /* [out] */ MemoryBuf * pOutBuffer,
        /* [out] */ IEvent * * ppCompletionEvent);

    // It's Maybe have no use for the disk driver.
    virtual void Dispose() {}
public:
    //HRESULT CreateMemPart(CMemDisk *pDisk, UINT offset, UINT size);
    BOOL initFileDisk(void);
    ECode OpenDisk(wchar_t *pName);
    ECode CloseDisk(void);
public:
    UINT64      m_DiskSize;
    wchar_t     m_wszFileName[20];
};

#endif//__FILEDISK_H__
